<template>
  <div>
    <a-modal
      centered
      :title="title"
      :width="1000"
      :visible="visible"
      @ok="handleOk"
      @cancel="handleCancel"
      cancelText="关闭">


      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline">
          <a-form-item label="用户账号">
            <a-input autocomplete="off" placeholder="" v-model="queryParam.username.value"></a-input>
          </a-form-item>
          <a-form-item label="机构">
            <ak-tree-select-multiple :url="sysDepartUrl.tree" v-model="queryParam.depart.value"/>
          </a-form-item>
          <a-form-item label="姓名">
            <a-input autocomplete="off" placeholder="请输入姓名查询" v-model="queryParam.realname.value"></a-input>
          </a-form-item>
          <a-form-item label="邮箱">
            <a-input autocomplete="off" placeholder="请输入邮箱查询" v-model="queryParam.email.value"></a-input>
          </a-form-item>

          <a-form-item label="手机号码">
            <a-input autocomplete="off" placeholder="请输入手机号码查询" v-model="queryParam.phone.value"></a-input>
          </a-form-item>
          <a-form-item >
                    <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                      <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                      <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
                    </span>
          </a-form-item>
        </a-form>
      </div>
      <!-- table区域-begin -->
      <div>
        <a-table
          size="small"
          bordered
          rowKey="id"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="ipagination"
          :loading="loading"
          :scroll="{ y: 240 }"
          :rowSelection="{selectedRowKeys: selectedRowKeys,onChange: onSelectChange}"
          @change="handleTableChange">

        </a-table>
      </div>
      <!-- table区域-end -->


    </a-modal>
  </div>
</template>

<script>
  import {sysUserUrl,sysDepartUrl} from '../../../api/url'
  import {getAction} from '../../../api/manage'
  import AkfhListMixin from '../../../mixin/AkfhListMixin'
  import AkTreeSelectMultiple from "../../../components/akfh/AkTreeSelectMultiple";

  export default {
    name: "SelectUserModal",
    components: {AkTreeSelectMultiple},
    mixins:[AkfhListMixin],
    data() {
      return {
        jobList:[],
        title: "添加已有用户",
        description: '用户选择',
        visible:false, // 是否展示
        // 查询条件
        queryParam:{
          username:{
            column:'username',
            type:'like',
            value:''
          },
          depart:{
            column:'sysDepart.id',
            type:'in',
            value:''
          },
          realname:{
            column:'realname',
            type:'like',
            value:''
          },
          email:{
            column:'email',
            type:'like',
            value:''
          },
          phone:{
            column:'phone',
            type:'like',
            value:''
          }
        },
        columns: [
          {
            title: '机构',
            align: 'center',
            dataIndex: 'sysDepartName',
            scopedSlots: { customRender: "ellipsis" }
          },
          {
            title: '账号',
            align: 'center',
            dataIndex: 'username',
            scopedSlots: { customRender: "ellipsis" }
          },
          {
            title: '姓名',
            align: 'center',
            dataIndex: 'realname',
            scopedSlots: { customRender: "ellipsis" }
          },
          {
            title: '手机号码',
            align: 'center',
            dataIndex: 'phone',
            scopedSlots: { customRender: "ellipsis" }
          },
          {
            title: '邮箱',
            align: 'center',
            dataIndex: 'email',
            scopedSlots: { customRender: "ellipsis" }
          },
          {
            title: '状态',
            align: 'center',
            dataIndex: 'status_dictText'
          }
          ],
        sysDepartUrl:sysDepartUrl,
        url: {
          list: sysUserUrl.list,
        }
      }
    },
    mounted(){

    },
    methods: {

      handleCancel() {
        this.visible = false;
        this.selectedRowKeys=[];
      },
      handleOk() {
        if(this.selectedRowKeys.length == 0){
          this.$message.warn("请至少选择一条数据");
          return;
        }
        this.$emit("selectFinished", this.selectedRowKeys);
        this.handleCancel();
      },

    }
  }
</script>
<style lang="less" scoped>
  .ant-card-body .table-operator {
    margin-bottom: 18px;
  }

  .ant-table-tbody .ant-table-row td {
    padding-top: 15px;
    padding-bottom: 15px;
  }

  .anty-row-operator button {
    margin: 0 5px
  }

  .ant-btn-danger {
    background-color: #ffffff
  }

  .ant-modal-cust-warp {
    height: 100%
  }

  .ant-modal-cust-warp .ant-modal-body {
    height: calc(100% - 110px) !important;
    overflow-y: auto
  }

  .ant-modal-cust-warp .ant-modal-content {
    height: 90% !important;
    overflow-y: hidden
  }
</style>
